import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store/index'
import filters from './filters/index'
import './utils/rem'
import './style/common.scss';


import Element from './views/common/common-element' // 按需引入element-ui组件
import "element-ui/lib/theme-chalk/index.css"; // element-ui样式
Vue.use(Element);

import VueAMap  from 'vue-amap';

Vue.use(VueAMap);

import Moment from 'moment'
Vue.prototype.moment = Moment

// 初始化vue-amap
VueAMap.initAMapApiLoader({
    // 高德key
    key: 'b8e7e29b0d49ea08f7359cf9f501f86f',
    // 插件集合 （插件按需引入）
    plugin: ['AMap.Autocomplete',   //输入提示插件
        'AMap.PlaceSearch',   //POI搜索插件
        'AMap.Scale',   //右下角缩略图插件 比例尺
        'AMap.OverView',   //地图鹰眼插件
        'AMap.ToolBar',   //地图工具条
        'AMap.MapType',   //类别切换控件，实现默认图层与卫星图、实施交通图层之间切换的控制
        'AMap.PolyEditor',   //编辑 折线多，边形
        'AMap.CircleEditor',   //圆形编辑器插件
        'AMap.HeatMap',
        'AMap.MarkerClusterer',
        'AMap.ControlBar',
        'AMap.Geolocation', // 用户主机所在的经纬度位置
      ],
    v: '1.4.4'
});

/*lazyAMapApiLoaderInstance.load().then(() => {
    this.map = new AMap.Map('amapContainer', {
        center: new AMap.LngLat(121.59996, 31.197646)
    });
});*/

// 注入全局过滤器
Object.keys(filters).forEach(item => {
    Vue.filter(item, filters[item])
});

import {
    Message,
    MessageBox
} from "element-ui";

Message.install = function(Vue) {
    Vue.prototype.msgSuccess = function(msg) {
        Message({
            showClose: false,
            message: msg,
            type: "success"
        });
    }

    Vue.prototype.msgError = function(msg) {
        Message({
            showClose: false,
            message: msg,
            type: "error"
        });
    }

    Vue.prototype.msgWarning = function(msg) {
        Message({
            showClose: false,
            message: msg,
            type: "warning"
        });
    }

    Vue.prototype.msgInfo = function(msg) {
        this.$message.info(msg);
    }
}

Vue.use(Message);
Vue.prototype.$message = Message;
Vue.prototype.$messageBox = MessageBox;

Vue.config.productionTip = false;
Vue.config.devtools = true;

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
